package com.java.io.byte_stream;

import java.io.*;

/**
 * 字节流缓冲区拷贝文件
 */
public class BufferedCopyFile {

    // 通过字节流的缓冲区完成复制。
    public static void copyFile(String orgPath, String desPath, String orgFileName, String desFileName)throws IOException {
        BufferedInputStream bufis = new BufferedInputStream(new FileInputStream(orgPath + orgFileName));
        BufferedOutputStream bufos = new BufferedOutputStream(new FileOutputStream(desPath + desFileName));

        int by = 0;
        while((by = bufis.read()) != -1) {
            bufos.write(by);
        }
        bufos.close();
        bufis.close();
    }


}
